{include "Public/header"}
<link rel="stylesheet" type="text/css" href="__CONTENT__/Admin/css/uploadify.css">
	<div class="page_tit">{$title}</div>
	<!-- START CONFIG_FORM -->
	<form method="POST" action="">
	{if isset($_GET['id'])}
	<input type="hidden" name="id" value="{:intval($_GET['id'])}" />
	{/if}
		<div class="form2">
			<dl class="lineD">
				<dt>
					<font color="red">*</font>品牌：
				</dt>
				<dd>
					<input name="name" maxlength="50" type="text" value="{$info['name']|''}" class="s-big-txt">
				</dd>
			</dl>
			<dl class="lineD">
				<dt>
					<font color="red">*</font>缩略图：
				</dt>
				<dd>
					<input type="file" id="thumbnail" />
					<div id="show-thumbnail">
					{if isset($info)}
						<img src="__UPLOAD__/{$info['thumbnail']}" /> 
						<a href="#" id="delete-thumbnail">删除</a>
					{/if}
					</div>
					<input type="hidden" name="thumbnail" value="{$info['thumbnail']|''}" />
				</dd>
			</dl>
			<dl class="lineD">
				<dt>
					<font color="red">*</font>排序：
				</dt>
				<dd>
					<input name="sort" maxlength="5" type="text" value="{$info['sort']|'50'}" class="small-s-txt">
					<font color="red">*</font>排序按照升序进行排列
				</dd>
			</dl>
			<div class="page_btm">
				<input type="submit" class="btn_b" value="保存"  />
			</div>
		</div>
	</form>
	<!-- END CONFIG_FORM -->
</div>
<script src="__CONTENT__/Admin/js/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(function(){
	$("form").validate({
		rules : {
			name: {
				required : true,
				rangelength : [ 1, 50 ]
			},
			sort : {
				required:true,
				digits : true
			}
		},
		messages:{
			name:{
				required:"品牌必须填写",
				rangelength:"品牌必须在1-50个字之间"
			},
			sort:{
				required:"排序必须填写",
				digits:"排序必须为数字"
			}
		}
	});
	setTimeout(function(){
		$('#thumbnail').uploadify({
			swf      : '__CONTENT__/swf/uploadify.swf',
			uploader : '{:U('Public/upload')}',
			buttonText:"上传缩略图",
			fileTypeDesc : '图片文件',
			fileTypeExts : '*.gif; *.jpg; *.png;*.jpeg',
			height:25,
			width:100,
			multi:false,
			onUploadSuccess : function(file, data, response) {
				data=eval('('+data+')');
				if(data.status==true){
					$("#show-thumbnail").html('<img src="__UPLOAD__/'+data.fileInfo.savename+'" /> <a href="#" id="delete-thumbnail">删除</a>');
					$("input[name='thumbnail']").val(data.fileInfo.savename);
				}else{
					alert(data.error_message);
				}
	        }
		});
	},10)
	$(document).on("click","#delete-thumbnail",function(){
		$("#show-thumbnail").empty();
		$("input[name='thumbnail']").val('');
	});
});
</script>
</html>